-------------------------------------------------------------------------------
--
-- | 
-- Module      :  Language.XMLSchema.XmlInstances 
-- Copyright   :  (c) Ricardo Vilaça 2005
-- License     :  LGPL
-- 
-- Maintainer  :  joost.visser@di.uminho.pt
-- Stability   :  experimental
-- Portability :  portable
--
-- This module contains the instances definitions for  XmlContent or XmlAttributes
-- for the XML Schema abstract syntax of "Language.XMLSchema.Syntax". These instances
-- were generated with DtdToHaskell tool from HaXml.
--
-------------------------------------------------------------------------------

module Language.XMLSchema.XmlInstances where

import Text.XML.HaXml.Xml2Haskell
import Text.XML.HaXml.OneOfN
import Language.XMLSchema.Syntax

{-Instance decls-}

instance XmlContent Xs'simpleType where
    fromElem (CElem (Elem "xs:simpleType" as c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (Just (Xs'simpleType (fromAttrs as) a b), rest))
	   (definite fromElem "OneOf" "xs:simpleType" ca))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'simpleType as a b) =
	[CElem (Elem "xs:simpleType" (toAttrs as) (maybe [] toElem a ++
						   toElem b))]
instance XmlAttributes Xs'simpleType_Attrs where
    fromAttrs as =
	Xs'simpleType_Attrs
	  { xs'simpleTypeName = possibleA fromAttrToStr "name" as
	  , xs'simpleTypeId = possibleA fromAttrToStr "id" as
	  }
    toAttrs v = catMaybes 
	[ maybeToAttr toAttrFrStr "name" (xs'simpleTypeName v)
	, maybeToAttr toAttrFrStr "id" (xs'simpleTypeId v)
	]
instance XmlContent Xs'restriction where
    fromElem (CElem (Elem "xs:restriction" as c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (\(c,cc)->
		 (Just (Xs'restriction (fromAttrs as) a b c), rest))
	      (definite fromElem "(((xs:attribute|xs:attributeGroup)*,(xs:anyAttribute)?))" "xs:restriction" cb))
	   (definite fromElem "OneOf" "xs:restriction" ca))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'restriction as a b c) =
	[CElem (Elem "xs:restriction" (toAttrs as) (maybe [] toElem a ++
						    toElem b ++ toElem c))]
instance XmlAttributes Xs'restriction_Attrs where
    fromAttrs as =
	Xs'restriction_Attrs
	  { xs'restrictionBase = possibleA fromAttrToStr "base" as
	  , xs'restrictionId = possibleA fromAttrToStr "id" as
	  }
    toAttrs v = catMaybes 
	[ maybeToAttr toAttrFrStr "base" (xs'restrictionBase v)
	, maybeToAttr toAttrFrStr "id" (xs'restrictionId v)
	]
instance XmlContent Xs'list where
    fromElem (CElem (Elem "xs:list" as c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (Just (Xs'list (fromAttrs as) a b), rest))
	   (fromElem ca))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'list as a b) =
	[CElem (Elem "xs:list" (toAttrs as) (maybe [] toElem a ++
						  maybe [] toElem b))]
instance XmlAttributes Xs'list_Attrs where
    fromAttrs as =
	Xs'list_Attrs
	  { xs'listItemType = possibleA fromAttrToStr "itemType" as
	  , xs'listId = possibleA fromAttrToStr "id" as
	  }
    toAttrs v = catMaybes 
	[ maybeToAttr toAttrFrStr "itemType" (xs'listItemType v)
	, maybeToAttr toAttrFrStr "id" (xs'listId v)
	]
instance XmlContent Xs'union where
    fromElem (CElem (Elem "xs:union" as c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (Just (Xs'union (fromAttrs as) a b), rest))
	   (many fromElem ca))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'union as a b) =
	[CElem (Elem "xs:union" (toAttrs as) (maybe [] toElem a ++
					      concatMap toElem b))]
instance XmlAttributes Xs'union_Attrs where
    fromAttrs as =
	Xs'union_Attrs
	  { xs'unionId = possibleA fromAttrToStr "id" as
	  , xs'unionMemberTypes = possibleA fromAttrToStr "memberTypes" as
	  }
    toAttrs v = catMaybes 
	[ maybeToAttr toAttrFrStr "id" (xs'unionId v)
	, maybeToAttr toAttrFrStr "memberTypes" (xs'unionMemberTypes v)
	]
instance XmlContent Xs'maxExclusive where
    fromElem (CElem (Elem "xs:maxExclusive" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'maxExclusive (fromAttrs as) a), rest))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'maxExclusive as a) =
	[CElem (Elem "xs:maxExclusive" (toAttrs as) (maybe [] toElem a))]
instance XmlAttributes Xs'maxExclusive_Attrs where
    fromAttrs as =
	Xs'maxExclusive_Attrs
	  { xs'maxExclusiveValue = definiteA fromAttrToStr "xs:maxExclusive" "value" as
	  , xs'maxExclusiveFixed = possibleA fromAttrToTyp "fixed" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "value" (xs'maxExclusiveValue v)
	, maybeToAttr toAttrFrTyp "fixed" (xs'maxExclusiveFixed v)
	]
instance XmlAttrType Xs'maxExclusive_fixed where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "true" = Just Xs'maxExclusive_fixed_true
	    translate "false" = Just Xs'maxExclusive_fixed_false
	    translate _ = Nothing
    toAttrFrTyp n Xs'maxExclusive_fixed_true = Just (n, str2attr "true")
    toAttrFrTyp n Xs'maxExclusive_fixed_false = Just (n, str2attr "false")
instance XmlContent Xs'minExclusive where
    fromElem (CElem (Elem "xs:minExclusive" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'minExclusive (fromAttrs as) a), rest))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'minExclusive as a) =
	[CElem (Elem "xs:minExclusive" (toAttrs as) (maybe [] toElem a))]
instance XmlAttributes Xs'minExclusive_Attrs where
    fromAttrs as =
	Xs'minExclusive_Attrs
	  { xs'minExclusiveValue = definiteA fromAttrToStr "xs:minExclusive" "value" as
	  , xs'minExclusiveFixed = possibleA fromAttrToTyp "fixed" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "value" (xs'minExclusiveValue v)
	, maybeToAttr toAttrFrTyp "fixed" (xs'minExclusiveFixed v)
	]
instance XmlAttrType Xs'minExclusive_fixed where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "true" = Just Xs'minExclusive_fixed_true
	    translate "false" = Just Xs'minExclusive_fixed_false
	    translate _ = Nothing
    toAttrFrTyp n Xs'minExclusive_fixed_true = Just (n, str2attr "true")
    toAttrFrTyp n Xs'minExclusive_fixed_false = Just (n, str2attr "false")
instance XmlContent Xs'maxInclusive where
    fromElem (CElem (Elem "xs:maxInclusive" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'maxInclusive (fromAttrs as) a), rest))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'maxInclusive as a) =
	[CElem (Elem "xs:maxInclusive" (toAttrs as) (maybe [] toElem a))]
instance XmlAttributes Xs'maxInclusive_Attrs where
    fromAttrs as =
	Xs'maxInclusive_Attrs
	  { xs'maxInclusiveValue = definiteA fromAttrToStr "xs:maxInclusive" "value" as
	  , xs'maxInclusiveFixed = possibleA fromAttrToTyp "fixed" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "value" (xs'maxInclusiveValue v)
	, maybeToAttr toAttrFrTyp "fixed" (xs'maxInclusiveFixed v)
	]
instance XmlAttrType Xs'maxInclusive_fixed where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "true" = Just Xs'maxInclusive_fixed_true
	    translate "false" = Just Xs'maxInclusive_fixed_false
	    translate _ = Nothing
    toAttrFrTyp n Xs'maxInclusive_fixed_true = Just (n, str2attr "true")
    toAttrFrTyp n Xs'maxInclusive_fixed_false = Just (n, str2attr "false")
instance XmlContent Xs'minInclusive where
    fromElem (CElem (Elem "xs:minInclusive" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'minInclusive (fromAttrs as) a), rest))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'minInclusive as a) =
	[CElem (Elem "xs:minInclusive" (toAttrs as) (maybe [] toElem a))]
instance XmlAttributes Xs'minInclusive_Attrs where
    fromAttrs as =
	Xs'minInclusive_Attrs
	  { xs'minInclusiveValue = definiteA fromAttrToStr "xs:minInclusive" "value" as
	  , xs'minInclusiveFixed = possibleA fromAttrToTyp "fixed" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "value" (xs'minInclusiveValue v)
	, maybeToAttr toAttrFrTyp "fixed" (xs'minInclusiveFixed v)
	]
instance XmlAttrType Xs'minInclusive_fixed where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "true" = Just Xs'minInclusive_fixed_true
	    translate "false" = Just Xs'minInclusive_fixed_false
	    translate _ = Nothing
    toAttrFrTyp n Xs'minInclusive_fixed_true = Just (n, str2attr "true")
    toAttrFrTyp n Xs'minInclusive_fixed_false = Just (n, str2attr "false")
instance XmlContent Xs'precision where
    fromElem (CElem (Elem "xs:precision" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'precision (fromAttrs as) a), rest))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'precision as a) =
	[CElem (Elem "xs:precision" (toAttrs as) (maybe [] toElem a))]
instance XmlAttributes Xs'precision_Attrs where
    fromAttrs as =
	Xs'precision_Attrs
	  { xs'precisionValue = definiteA fromAttrToStr "xs:precision" "value" as
	  , xs'precisionFixed = possibleA fromAttrToTyp "fixed" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "value" (xs'precisionValue v)
	, maybeToAttr toAttrFrTyp "fixed" (xs'precisionFixed v)
	]
instance XmlAttrType Xs'precision_fixed where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "true" = Just Xs'precision_fixed_true
	    translate "false" = Just Xs'precision_fixed_false
	    translate _ = Nothing
    toAttrFrTyp n Xs'precision_fixed_true = Just (n, str2attr "true")
    toAttrFrTyp n Xs'precision_fixed_false = Just (n, str2attr "false")
instance XmlContent Xs'scale where
    fromElem (CElem (Elem "xs:scale" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'scale (fromAttrs as) a), rest))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'scale as a) =
	[CElem (Elem "xs:scale" (toAttrs as) (maybe [] toElem a))]
instance XmlAttributes Xs'scale_Attrs where
    fromAttrs as =
	Xs'scale_Attrs
	  { xs'scaleValue = definiteA fromAttrToStr "xs:scale" "value" as
	  , xs'scaleFixed = possibleA fromAttrToTyp "fixed" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "value" (xs'scaleValue v)
	, maybeToAttr toAttrFrTyp "fixed" (xs'scaleFixed v)
	]
instance XmlAttrType Xs'scale_fixed where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "true" = Just Xs'scale_fixed_true
	    translate "false" = Just Xs'scale_fixed_false
	    translate _ = Nothing
    toAttrFrTyp n Xs'scale_fixed_true = Just (n, str2attr "true")
    toAttrFrTyp n Xs'scale_fixed_false = Just (n, str2attr "false")
instance XmlContent Xs'length where
    fromElem (CElem (Elem "xs:length" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'length (fromAttrs as) a), rest))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'length as a) =
	[CElem (Elem "xs:length" (toAttrs as) (maybe [] toElem a))]
instance XmlAttributes Xs'length_Attrs where
    fromAttrs as =
	Xs'length_Attrs
	  { xs'lengthValue = definiteA fromAttrToStr "xs:length" "value" as
	  , xs'lengthFixed = possibleA fromAttrToTyp "fixed" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "value" (xs'lengthValue v)
	, maybeToAttr toAttrFrTyp "fixed" (xs'lengthFixed v)
	]
instance XmlAttrType Xs'length_fixed where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "true" = Just Xs'length_fixed_true
	    translate "false" = Just Xs'length_fixed_false
	    translate _ = Nothing
    toAttrFrTyp n Xs'length_fixed_true = Just (n, str2attr "true")
    toAttrFrTyp n Xs'length_fixed_false = Just (n, str2attr "false")
instance XmlContent Xs'minLength where
    fromElem (CElem (Elem "xs:minLength" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'minLength (fromAttrs as) a), rest))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'minLength as a) =
	[CElem (Elem "xs:minLength" (toAttrs as) (maybe [] toElem a))]
instance XmlAttributes Xs'minLength_Attrs where
    fromAttrs as =
	Xs'minLength_Attrs
	  { xs'minLengthValue = definiteA fromAttrToStr "xs:minLength" "value" as
	  , xs'minLengthFixed = possibleA fromAttrToTyp "fixed" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "value" (xs'minLengthValue v)
	, maybeToAttr toAttrFrTyp "fixed" (xs'minLengthFixed v)
	]
instance XmlAttrType Xs'minLength_fixed where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "true" = Just Xs'minLength_fixed_true
	    translate "false" = Just Xs'minLength_fixed_false
	    translate _ = Nothing
    toAttrFrTyp n Xs'minLength_fixed_true = Just (n, str2attr "true")
    toAttrFrTyp n Xs'minLength_fixed_false = Just (n, str2attr "false")
instance XmlContent Xs'maxLength where
    fromElem (CElem (Elem "xs:maxLength" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'maxLength (fromAttrs as) a), rest))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'maxLength as a) =
	[CElem (Elem "xs:maxLength" (toAttrs as) (maybe [] toElem a))]
instance XmlAttributes Xs'maxLength_Attrs where
    fromAttrs as =
	Xs'maxLength_Attrs
	  { xs'maxLengthValue = definiteA fromAttrToStr "xs:maxLength" "value" as
	  , xs'maxLengthFixed = possibleA fromAttrToTyp "fixed" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "value" (xs'maxLengthValue v)
	, maybeToAttr toAttrFrTyp "fixed" (xs'maxLengthFixed v)
	]
instance XmlAttrType Xs'maxLength_fixed where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "true" = Just Xs'maxLength_fixed_true
	    translate "false" = Just Xs'maxLength_fixed_false
	    translate _ = Nothing
    toAttrFrTyp n Xs'maxLength_fixed_true = Just (n, str2attr "true")
    toAttrFrTyp n Xs'maxLength_fixed_false = Just (n, str2attr "false")
instance XmlContent Xs'enumeration where
    fromElem (CElem (Elem "xs:enumeration" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'enumeration (fromAttrs as) a), rest))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'enumeration as a) =
	[CElem (Elem "xs:enumeration" (toAttrs as) (maybe [] toElem a))]
instance XmlAttributes Xs'enumeration_Attrs where
    fromAttrs as =
	Xs'enumeration_Attrs
	  { xs'enumerationValue = definiteA fromAttrToStr "xs:enumeration" "value" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "value" (xs'enumerationValue v)
	]
instance XmlContent Xs'whiteSpace where
    fromElem (CElem (Elem "xs:whiteSpace" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'whiteSpace (fromAttrs as) a), rest))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'whiteSpace as a) =
	[CElem (Elem "xs:whiteSpace" (toAttrs as) (maybe [] toElem a))]
instance XmlAttributes Xs'whiteSpace_Attrs where
    fromAttrs as =
	Xs'whiteSpace_Attrs
	  { xs'whiteSpaceValue = definiteA fromAttrToStr "xs:whiteSpace" "value" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "value" (xs'whiteSpaceValue v)
	]
instance XmlContent Xs'pattern where
    fromElem (CElem (Elem "xs:pattern" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'pattern (fromAttrs as) a), rest))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'pattern as a) =
	[CElem (Elem "xs:pattern" (toAttrs as) (maybe [] toElem a))]
instance XmlAttributes Xs'pattern_Attrs where
    fromAttrs as =
	Xs'pattern_Attrs
	  { xs'patternValue = definiteA fromAttrToStr "xs:pattern" "value" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "value" (xs'patternValue v)
	]
instance XmlContent Xs'encoding where
    fromElem (CElem (Elem "xs:encoding" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'encoding (fromAttrs as) a), rest))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'encoding as a) =
	[CElem (Elem "xs:encoding" (toAttrs as) (maybe [] toElem a))]
instance XmlAttributes Xs'encoding_Attrs where
    fromAttrs as =
	Xs'encoding_Attrs
	  { xs'encodingValue = definiteA fromAttrToStr "xs:encoding" "value" as
	  , xs'encodingFixed = possibleA fromAttrToTyp "fixed" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "value" (xs'encodingValue v)
	, maybeToAttr toAttrFrTyp "fixed" (xs'encodingFixed v)
	]
instance XmlAttrType Xs'encoding_fixed where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "true" = Just Xs'encoding_fixed_true
	    translate "false" = Just Xs'encoding_fixed_false
	    translate _ = Nothing
    toAttrFrTyp n Xs'encoding_fixed_true = Just (n, str2attr "true")
    toAttrFrTyp n Xs'encoding_fixed_false = Just (n, str2attr "false")
instance XmlContent Xs'period where
    fromElem (CElem (Elem "xs:period" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'period (fromAttrs as) a), rest))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'period as a) =
	[CElem (Elem "xs:period" (toAttrs as) (maybe [] toElem a))]
instance XmlAttributes Xs'period_Attrs where
    fromAttrs as =
	Xs'period_Attrs
	  { xs'periodValue = definiteA fromAttrToStr "xs:period" "value" as
	  , xs'periodFixed = possibleA fromAttrToTyp "fixed" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "value" (xs'periodValue v)
	, maybeToAttr toAttrFrTyp "fixed" (xs'periodFixed v)
	]
instance XmlAttrType Xs'period_fixed where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "true" = Just Xs'period_fixed_true
	    translate "false" = Just Xs'period_fixed_false
	    translate _ = Nothing
    toAttrFrTyp n Xs'period_fixed_true = Just (n, str2attr "true")
    toAttrFrTyp n Xs'period_fixed_false = Just (n, str2attr "false")
instance XmlContent Xs'duration where
    fromElem (CElem (Elem "xs:duration" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'duration (fromAttrs as) a), rest))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'duration as a) =
	[CElem (Elem "xs:duration" (toAttrs as) (maybe [] toElem a))]
instance XmlAttributes Xs'duration_Attrs where
    fromAttrs as =
	Xs'duration_Attrs
	  { xs'durationValue = definiteA fromAttrToStr "xs:duration" "value" as
	  , xs'durationFixed = possibleA fromAttrToTyp "fixed" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "value" (xs'durationValue v)
	, maybeToAttr toAttrFrTyp "fixed" (xs'durationFixed v)
	]
instance XmlAttrType Xs'duration_fixed where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "true" = Just Xs'duration_fixed_true
	    translate "false" = Just Xs'duration_fixed_false
	    translate _ = Nothing
    toAttrFrTyp n Xs'duration_fixed_true = Just (n, str2attr "true")
    toAttrFrTyp n Xs'duration_fixed_false = Just (n, str2attr "false")
instance XmlContent Xs'schema where
    fromElem (CElem (Elem "xs:schema" as c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (Just (Xs'schema (fromAttrs as) a b), rest))
	   (many fromElem ca))
	(many fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'schema as a b) =
	[CElem (Elem "xs:schema" (toAttrs as) (concatMap toElem a ++
					       concatMap toElem b))]
instance XmlAttributes Xs'schema_Attrs where
    fromAttrs as =
	Xs'schema_Attrs
	  { xs'schemaTargetNamespace = possibleA fromAttrToStr "targetNamespace" as
	  , xs'schemaVersion = possibleA fromAttrToStr "version" as
	  , xs'schemaXmlns'xs = defaultA fromAttrToStr "http://www.w3.org/2001/XMLSchema" "xmlns:xs" as
	  , xs'schemaXmlns = possibleA fromAttrToStr "xmlns" as
	  , xs'schemaFinalDefault = defaultA fromAttrToStr "" "finalDefault" as
	  , xs'schemaBlockDefault = defaultA fromAttrToStr "" "blockDefault" as
	  , xs'schemaId = possibleA fromAttrToStr "id" as
	  , xs'schemaElementFormDefault = defaultA fromAttrToTyp Xs'schema_elementFormDefault_unqualified "elementFormDefault" as
	  , xs'schemaAttributeFormDefault = defaultA fromAttrToTyp Xs'schema_attributeFormDefault_unqualified "attributeFormDefault" as
	  , xs'schemaXml'lang = possibleA fromAttrToStr "xml:lang" as
	  }
    toAttrs v = catMaybes 
	[ maybeToAttr toAttrFrStr "targetNamespace" (xs'schemaTargetNamespace v)
	, maybeToAttr toAttrFrStr "version" (xs'schemaVersion v)
	, defaultToAttr toAttrFrStr "xmlns:xs" (xs'schemaXmlns'xs v)
	, maybeToAttr toAttrFrStr "xmlns" (xs'schemaXmlns v)
	, defaultToAttr toAttrFrStr "finalDefault" (xs'schemaFinalDefault v)
	, defaultToAttr toAttrFrStr "blockDefault" (xs'schemaBlockDefault v)
	, maybeToAttr toAttrFrStr "id" (xs'schemaId v)
	, defaultToAttr toAttrFrTyp "elementFormDefault" (xs'schemaElementFormDefault v)
	, defaultToAttr toAttrFrTyp "attributeFormDefault" (xs'schemaAttributeFormDefault v)
	, maybeToAttr toAttrFrStr "xml:lang" (xs'schemaXml'lang v)
	]
instance XmlAttrType Xs'schema_elementFormDefault where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "qualified" = Just Xs'schema_elementFormDefault_qualified
	    translate "unqualified" = Just Xs'schema_elementFormDefault_unqualified
	    translate _ = Nothing
    toAttrFrTyp n Xs'schema_elementFormDefault_qualified = Just (n, str2attr "qualified")
    toAttrFrTyp n Xs'schema_elementFormDefault_unqualified = Just (n, str2attr "unqualified")
instance XmlAttrType Xs'schema_attributeFormDefault where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "qualified" = Just Xs'schema_attributeFormDefault_qualified
	    translate "unqualified" = Just Xs'schema_attributeFormDefault_unqualified
	    translate _ = Nothing
    toAttrFrTyp n Xs'schema_attributeFormDefault_qualified = Just (n, str2attr "qualified")
    toAttrFrTyp n Xs'schema_attributeFormDefault_unqualified = Just (n, str2attr "unqualified")
instance XmlContent Xs'complexType where
    fromElem (CElem (Elem "xs:complexType" as c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (Just (Xs'complexType (fromAttrs as) a b), rest))
	   (definite fromElem "OneOf" "xs:complexType" ca))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'complexType as a b) =
	[CElem (Elem "xs:complexType" (toAttrs as) (maybe [] toElem a ++
						    toElem b))]
instance XmlAttributes Xs'complexType_Attrs where
    fromAttrs as =
	Xs'complexType_Attrs
	  { xs'complexTypeName = possibleA fromAttrToStr "name" as
	  , xs'complexTypeId = possibleA fromAttrToStr "id" as
	  , xs'complexTypeAbstract = possibleA fromAttrToTyp "abstract" as
	  , xs'complexTypeFinal = possibleA fromAttrToStr "final" as
	  , xs'complexTypeBlock = possibleA fromAttrToStr "block" as
	  , xs'complexTypeMixed = defaultA fromAttrToTyp Xs'complexType_mixed_false "mixed" as
	  }
    toAttrs v = catMaybes 
	[ maybeToAttr toAttrFrStr "name" (xs'complexTypeName v)
	, maybeToAttr toAttrFrStr "id" (xs'complexTypeId v)
	, maybeToAttr toAttrFrTyp "abstract" (xs'complexTypeAbstract v)
	, maybeToAttr toAttrFrStr "final" (xs'complexTypeFinal v)
	, maybeToAttr toAttrFrStr "block" (xs'complexTypeBlock v)
	, defaultToAttr toAttrFrTyp "mixed" (xs'complexTypeMixed v)
	]
instance XmlAttrType Xs'complexType_abstract where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "true" = Just Xs'complexType_abstract_true
	    translate "false" = Just Xs'complexType_abstract_false
	    translate _ = Nothing
    toAttrFrTyp n Xs'complexType_abstract_true = Just (n, str2attr "true")
    toAttrFrTyp n Xs'complexType_abstract_false = Just (n, str2attr "false")
instance XmlAttrType Xs'complexType_mixed where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "true" = Just Xs'complexType_mixed_true
	    translate "false" = Just Xs'complexType_mixed_false
	    translate _ = Nothing
    toAttrFrTyp n Xs'complexType_mixed_true = Just (n, str2attr "true")
    toAttrFrTyp n Xs'complexType_mixed_false = Just (n, str2attr "false")
instance XmlContent Xs'complexContent where
    fromElem (CElem (Elem "xs:complexContent" as c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (Just (Xs'complexContent (fromAttrs as) a b), rest))
	   (definite fromElem "OneOf" "xs:complexContent" ca))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'complexContent as a b) =
	[CElem (Elem "xs:complexContent" (toAttrs as) (maybe [] toElem a ++
						       toElem b))]
instance XmlAttributes Xs'complexContent_Attrs where
    fromAttrs as =
	Xs'complexContent_Attrs
	  { xs'complexContentMixed = possibleA fromAttrToTyp "mixed" as
	  , xs'complexContentId = possibleA fromAttrToStr "id" as
	  }
    toAttrs v = catMaybes 
	[ maybeToAttr toAttrFrTyp "mixed" (xs'complexContentMixed v)
	, maybeToAttr toAttrFrStr "id" (xs'complexContentId v)
	]
instance XmlAttrType Xs'complexContent_mixed where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "true" = Just Xs'complexContent_mixed_true
	    translate "false" = Just Xs'complexContent_mixed_false
	    translate _ = Nothing
    toAttrFrTyp n Xs'complexContent_mixed_true = Just (n, str2attr "true")
    toAttrFrTyp n Xs'complexContent_mixed_false = Just (n, str2attr "false")
instance XmlContent Xs'simpleContent where
    fromElem (CElem (Elem "xs:simpleContent" as c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (Just (Xs'simpleContent (fromAttrs as) a b), rest))
	   (definite fromElem "OneOf" "xs:simpleContent" ca))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'simpleContent as a b) =
	[CElem (Elem "xs:simpleContent" (toAttrs as) (maybe [] toElem a ++
						      toElem b))]
instance XmlAttributes Xs'simpleContent_Attrs where
    fromAttrs as =
	Xs'simpleContent_Attrs
	  { xs'simpleContentId = possibleA fromAttrToStr "id" as
	  }
    toAttrs v = catMaybes 
	[ maybeToAttr toAttrFrStr "id" (xs'simpleContentId v)
	]
instance XmlContent Xs'extension where
    fromElem (CElem (Elem "xs:extension" as c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (Just (Xs'extension (fromAttrs as) a b), rest))
	   (definite fromElem "(((xs:all|xs:choice|xs:sequence|xs:group)?,((xs:attribute|xs:attributeGroup)*,(xs:anyAttribute)?)))" "xs:extension" ca))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'extension as a b) =
	[CElem (Elem "xs:extension" (toAttrs as) (maybe [] toElem a ++
						  toElem b))]
instance XmlAttributes Xs'extension_Attrs where
    fromAttrs as =
	Xs'extension_Attrs
	  { xs'extensionBase = definiteA fromAttrToStr "xs:extension" "base" as
	  , xs'extensionId = possibleA fromAttrToStr "id" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "base" (xs'extensionBase v)
	, maybeToAttr toAttrFrStr "id" (xs'extensionId v)
	]
instance XmlContent Xs'element where
    fromElem (CElem (Elem "xs:element" as c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (\(c,cc)->
		 (Just (Xs'element (fromAttrs as) a b c), rest))
	      (many fromElem cb))
	   (fromElem ca))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'element as a b c) =
	[CElem (Elem "xs:element" (toAttrs as) (maybe [] toElem a ++
						maybe [] toElem b ++ concatMap toElem c))]
instance XmlAttributes Xs'element_Attrs where
    fromAttrs as =
	Xs'element_Attrs
	  { xs'elementName = possibleA fromAttrToStr "name" as
	  , xs'elementId = possibleA fromAttrToStr "id" as
	  , xs'elementRef = possibleA fromAttrToStr "ref" as
	  , xs'elementType = possibleA fromAttrToStr "type" as
	  , xs'elementMinOccurs = possibleA fromAttrToStr "minOccurs" as
	  , xs'elementMaxOccurs = possibleA fromAttrToStr "maxOccurs" as
	  , xs'elementNillable = possibleA fromAttrToTyp "nillable" as
	  , xs'elementSubstitutionGroup = possibleA fromAttrToStr "substitutionGroup" as
	  , xs'elementAbstract = possibleA fromAttrToTyp "abstract" as
	  , xs'elementFinal = possibleA fromAttrToStr "final" as
	  , xs'elementBlock = possibleA fromAttrToStr "block" as
	  , xs'elementDefault = possibleA fromAttrToStr "default" as
	  , xs'elementFixed = possibleA fromAttrToStr "fixed" as
	  , xs'elementForm = possibleA fromAttrToTyp "form" as
	  }
    toAttrs v = catMaybes 
	[ maybeToAttr toAttrFrStr "name" (xs'elementName v)
	, maybeToAttr toAttrFrStr "id" (xs'elementId v)
	, maybeToAttr toAttrFrStr "ref" (xs'elementRef v)
	, maybeToAttr toAttrFrStr "type" (xs'elementType v)
	, maybeToAttr toAttrFrStr "minOccurs" (xs'elementMinOccurs v)
	, maybeToAttr toAttrFrStr "maxOccurs" (xs'elementMaxOccurs v)
	, maybeToAttr toAttrFrTyp "nillable" (xs'elementNillable v)
	, maybeToAttr toAttrFrStr "substitutionGroup" (xs'elementSubstitutionGroup v)
	, maybeToAttr toAttrFrTyp "abstract" (xs'elementAbstract v)
	, maybeToAttr toAttrFrStr "final" (xs'elementFinal v)
	, maybeToAttr toAttrFrStr "block" (xs'elementBlock v)
	, maybeToAttr toAttrFrStr "default" (xs'elementDefault v)
	, maybeToAttr toAttrFrStr "fixed" (xs'elementFixed v)
	, maybeToAttr toAttrFrTyp "form" (xs'elementForm v)
	]
instance XmlAttrType Xs'element_nillable where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "true" = Just Xs'element_nillable_true
	    translate "false" = Just Xs'element_nillable_false
	    translate _ = Nothing
    toAttrFrTyp n Xs'element_nillable_true = Just (n, str2attr "true")
    toAttrFrTyp n Xs'element_nillable_false = Just (n, str2attr "false")
instance XmlAttrType Xs'element_abstract where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "true" = Just Xs'element_abstract_true
	    translate "false" = Just Xs'element_abstract_false
	    translate _ = Nothing
    toAttrFrTyp n Xs'element_abstract_true = Just (n, str2attr "true")
    toAttrFrTyp n Xs'element_abstract_false = Just (n, str2attr "false")
instance XmlAttrType Xs'element_form where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "qualified" = Just Xs'element_form_qualified
	    translate "unqualified" = Just Xs'element_form_unqualified
	    translate _ = Nothing
    toAttrFrTyp n Xs'element_form_qualified = Just (n, str2attr "qualified")
    toAttrFrTyp n Xs'element_form_unqualified = Just (n, str2attr "unqualified")
instance XmlContent Xs'group where
    fromElem (CElem (Elem "xs:group" as c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (Just (Xs'group (fromAttrs as) a b), rest))
	   (fromElem ca))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'group as a b) =
	[CElem (Elem "xs:group" (toAttrs as) (maybe [] toElem a ++
					      maybe [] toElem b))]
instance XmlAttributes Xs'group_Attrs where
    fromAttrs as =
	Xs'group_Attrs
	  { xs'groupName = possibleA fromAttrToStr "name" as
	  , xs'groupRef = possibleA fromAttrToStr "ref" as
	  , xs'groupMinOccurs = possibleA fromAttrToStr "minOccurs" as
	  , xs'groupMaxOccurs = possibleA fromAttrToStr "maxOccurs" as
	  , xs'groupId = possibleA fromAttrToStr "id" as
	  }
    toAttrs v = catMaybes 
	[ maybeToAttr toAttrFrStr "name" (xs'groupName v)
	, maybeToAttr toAttrFrStr "ref" (xs'groupRef v)
	, maybeToAttr toAttrFrStr "minOccurs" (xs'groupMinOccurs v)
	, maybeToAttr toAttrFrStr "maxOccurs" (xs'groupMaxOccurs v)
	, maybeToAttr toAttrFrStr "id" (xs'groupId v)
	]
instance XmlContent Xs'all where
    fromElem (CElem (Elem "xs:all" as c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (Just (Xs'all (fromAttrs as) a b), rest))
	   (many fromElem ca))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'all as a b) =
	[CElem (Elem "xs:all" (toAttrs as) (maybe [] toElem a ++
					    concatMap toElem b))]
instance XmlAttributes Xs'all_Attrs where
    fromAttrs as =
	Xs'all_Attrs
	  { xs'allMinOccurs = possibleA fromAttrToTyp "minOccurs" as
	  , xs'allMaxOccurs = possibleA fromAttrToTyp "maxOccurs" as
	  , xs'allId = possibleA fromAttrToStr "id" as
	  }
    toAttrs v = catMaybes 
	[ maybeToAttr toAttrFrTyp "minOccurs" (xs'allMinOccurs v)
	, maybeToAttr toAttrFrTyp "maxOccurs" (xs'allMaxOccurs v)
	, maybeToAttr toAttrFrStr "id" (xs'allId v)
	]
instance XmlAttrType Xs'all_minOccurs where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "1" = Just Xs'all_minOccurs_1
	    translate _ = Nothing
    toAttrFrTyp n Xs'all_minOccurs_1 = Just (n, str2attr "1")
instance XmlAttrType Xs'all_maxOccurs where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "1" = Just Xs'all_maxOccurs_1
	    translate _ = Nothing
    toAttrFrTyp n Xs'all_maxOccurs_1 = Just (n, str2attr "1")
instance XmlContent Xs'choice where
    fromElem (CElem (Elem "xs:choice" as c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (Just (Xs'choice (fromAttrs as) a b), rest))
	   (many fromElem ca))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'choice as a b) =
	[CElem (Elem "xs:choice" (toAttrs as) (maybe [] toElem a ++
					       concatMap toElem b))]
instance XmlAttributes Xs'choice_Attrs where
    fromAttrs as =
	Xs'choice_Attrs
	  { xs'choiceMinOccurs = possibleA fromAttrToStr "minOccurs" as
	  , xs'choiceMaxOccurs = possibleA fromAttrToStr "maxOccurs" as
	  , xs'choiceId = possibleA fromAttrToStr "id" as
	  }
    toAttrs v = catMaybes 
	[ maybeToAttr toAttrFrStr "minOccurs" (xs'choiceMinOccurs v)
	, maybeToAttr toAttrFrStr "maxOccurs" (xs'choiceMaxOccurs v)
	, maybeToAttr toAttrFrStr "id" (xs'choiceId v)
	]
instance XmlContent Xs'sequence where
    fromElem (CElem (Elem "xs:sequence" as c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (Just (Xs'sequence (fromAttrs as) a b), rest))
	   (many fromElem ca))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'sequence as a b) =
	[CElem (Elem "xs:sequence" (toAttrs as) (maybe [] toElem a ++
						 concatMap toElem b))]
instance XmlAttributes Xs'sequence_Attrs where
    fromAttrs as =
	Xs'sequence_Attrs
	  { xs'sequenceMinOccurs = possibleA fromAttrToStr "minOccurs" as
	  , xs'sequenceMaxOccurs = possibleA fromAttrToStr "maxOccurs" as
	  , xs'sequenceId = possibleA fromAttrToStr "id" as
	  }
    toAttrs v = catMaybes 
	[ maybeToAttr toAttrFrStr "minOccurs" (xs'sequenceMinOccurs v)
	, maybeToAttr toAttrFrStr "maxOccurs" (xs'sequenceMaxOccurs v)
	, maybeToAttr toAttrFrStr "id" (xs'sequenceId v)
	]
instance XmlContent Xs'any where
    fromElem (CElem (Elem "xs:any" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'any (fromAttrs as) a), rest))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'any as a) =
	[CElem (Elem "xs:any" (toAttrs as) (maybe [] toElem a))]
instance XmlAttributes Xs'any_Attrs where
    fromAttrs as =
	Xs'any_Attrs
	  { xs'anyNamespace = defaultA fromAttrToStr "##any" "namespace" as
	  , xs'anyProcessContents = defaultA fromAttrToTyp Xs'any_processContents_strict "processContents" as
	  , xs'anyMinOccurs = defaultA fromAttrToStr "1" "minOccurs" as
	  , xs'anyMaxOccurs = defaultA fromAttrToStr "1" "maxOccurs" as
	  , xs'anyId = possibleA fromAttrToStr "id" as
	  }
    toAttrs v = catMaybes 
	[ defaultToAttr toAttrFrStr "namespace" (xs'anyNamespace v)
	, defaultToAttr toAttrFrTyp "processContents" (xs'anyProcessContents v)
	, defaultToAttr toAttrFrStr "minOccurs" (xs'anyMinOccurs v)
	, defaultToAttr toAttrFrStr "maxOccurs" (xs'anyMaxOccurs v)
	, maybeToAttr toAttrFrStr "id" (xs'anyId v)
	]
instance XmlAttrType Xs'any_processContents where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "skip" = Just Xs'any_processContents_skip
	    translate "lax" = Just Xs'any_processContents_lax
	    translate "strict" = Just Xs'any_processContents_strict
	    translate _ = Nothing
    toAttrFrTyp n Xs'any_processContents_skip = Just (n, str2attr "skip")
    toAttrFrTyp n Xs'any_processContents_lax = Just (n, str2attr "lax")
    toAttrFrTyp n Xs'any_processContents_strict = Just (n, str2attr "strict")
instance XmlContent Xs'anyAttribute where
    fromElem (CElem (Elem "xs:anyAttribute" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'anyAttribute (fromAttrs as) a), rest))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'anyAttribute as a) =
	[CElem (Elem "xs:anyAttribute" (toAttrs as) (maybe [] toElem a))]
instance XmlAttributes Xs'anyAttribute_Attrs where
    fromAttrs as =
	Xs'anyAttribute_Attrs
	  { xs'anyAttributeNamespace = defaultA fromAttrToStr "##any" "namespace" as
	  , xs'anyAttributeProcessContents = defaultA fromAttrToTyp Xs'anyAttribute_processContents_strict "processContents" as
	  , xs'anyAttributeId = possibleA fromAttrToStr "id" as
	  }
    toAttrs v = catMaybes 
	[ defaultToAttr toAttrFrStr "namespace" (xs'anyAttributeNamespace v)
	, defaultToAttr toAttrFrTyp "processContents" (xs'anyAttributeProcessContents v)
	, maybeToAttr toAttrFrStr "id" (xs'anyAttributeId v)
	]
instance XmlAttrType Xs'anyAttribute_processContents where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "skip" = Just Xs'anyAttribute_processContents_skip
	    translate "lax" = Just Xs'anyAttribute_processContents_lax
	    translate "strict" = Just Xs'anyAttribute_processContents_strict
	    translate _ = Nothing
    toAttrFrTyp n Xs'anyAttribute_processContents_skip = Just (n, str2attr "skip")
    toAttrFrTyp n Xs'anyAttribute_processContents_lax = Just (n, str2attr "lax")
    toAttrFrTyp n Xs'anyAttribute_processContents_strict = Just (n, str2attr "strict")
instance XmlContent Xs'attribute where
    fromElem (CElem (Elem "xs:attribute" as c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (Just (Xs'attribute (fromAttrs as) a b), rest))
	   (fromElem ca))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'attribute as a b) =
	[CElem (Elem "xs:attribute" (toAttrs as) (maybe [] toElem a ++
						  maybe [] toElem b))]
instance XmlAttributes Xs'attribute_Attrs where
    fromAttrs as =
	Xs'attribute_Attrs
	  { xs'attributeName = possibleA fromAttrToStr "name" as
	  , xs'attributeId = possibleA fromAttrToStr "id" as
	  , xs'attributeRef = possibleA fromAttrToStr "ref" as
	  , xs'attributeType = possibleA fromAttrToStr "type" as
	  , xs'attributeUse = possibleA fromAttrToTyp "use" as
	  , xs'attributeDefault = possibleA fromAttrToStr "default" as
	  , xs'attributeFixed = possibleA fromAttrToStr "fixed" as
	  , xs'attributeForm = possibleA fromAttrToTyp "form" as
	  }
    toAttrs v = catMaybes 
	[ maybeToAttr toAttrFrStr "name" (xs'attributeName v)
	, maybeToAttr toAttrFrStr "id" (xs'attributeId v)
	, maybeToAttr toAttrFrStr "ref" (xs'attributeRef v)
	, maybeToAttr toAttrFrStr "type" (xs'attributeType v)
	, maybeToAttr toAttrFrTyp "use" (xs'attributeUse v)
	, maybeToAttr toAttrFrStr "default" (xs'attributeDefault v)
	, maybeToAttr toAttrFrStr "fixed" (xs'attributeFixed v)
	, maybeToAttr toAttrFrTyp "form" (xs'attributeForm v)
	]
instance XmlAttrType Xs'attribute_use where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "prohibited" = Just Xs'attribute_use_prohibited
	    translate "optional" = Just Xs'attribute_use_optional
	    translate "required" = Just Xs'attribute_use_required
	    translate _ = Nothing
    toAttrFrTyp n Xs'attribute_use_prohibited = Just (n, str2attr "prohibited")
    toAttrFrTyp n Xs'attribute_use_optional = Just (n, str2attr "optional")
    toAttrFrTyp n Xs'attribute_use_required = Just (n, str2attr "required")
instance XmlAttrType Xs'attribute_form where
    fromAttrToTyp n (n',v)
	| n==n'     = translate (attr2str v)
	| otherwise = Nothing
      where translate "qualified" = Just Xs'attribute_form_qualified
	    translate "unqualified" = Just Xs'attribute_form_unqualified
	    translate _ = Nothing
    toAttrFrTyp n Xs'attribute_form_qualified = Just (n, str2attr "qualified")
    toAttrFrTyp n Xs'attribute_form_unqualified = Just (n, str2attr "unqualified")
instance XmlContent Xs'attributeGroup where
    fromElem (CElem (Elem "xs:attributeGroup" as c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (\(c,cc)->
		 (Just (Xs'attributeGroup (fromAttrs as) a b c), rest))
	      (fromElem cb))
	   (many fromElem ca))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'attributeGroup as a b c) =
	[CElem (Elem "xs:attributeGroup" (toAttrs as) (maybe [] toElem a ++
						       concatMap toElem b ++ maybe [] toElem c))]
instance XmlAttributes Xs'attributeGroup_Attrs where
    fromAttrs as =
	Xs'attributeGroup_Attrs
	  { xs'attributeGroupName = possibleA fromAttrToStr "name" as
	  , xs'attributeGroupId = possibleA fromAttrToStr "id" as
	  , xs'attributeGroupRef = possibleA fromAttrToStr "ref" as
	  }
    toAttrs v = catMaybes 
	[ maybeToAttr toAttrFrStr "name" (xs'attributeGroupName v)
	, maybeToAttr toAttrFrStr "id" (xs'attributeGroupId v)
	, maybeToAttr toAttrFrStr "ref" (xs'attributeGroupRef v)
	]
instance XmlContent Xs'unique where
    fromElem (CElem (Elem "xs:unique" as c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (\(c,cc)->
		 (Just (Xs'unique (fromAttrs as) a b c), rest))
	      (definite fromElem "(xs:field)+" "xs:unique" cb))
	   (definite fromElem "<xs:selector>" "xs:unique" ca))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'unique as a b c) =
	[CElem (Elem "xs:unique" (toAttrs as) (maybe [] toElem a ++
					       toElem b ++ toElem c))]
instance XmlAttributes Xs'unique_Attrs where
    fromAttrs as =
	Xs'unique_Attrs
	  { xs'uniqueName = definiteA fromAttrToStr "xs:unique" "name" as
	  , xs'uniqueId = possibleA fromAttrToStr "id" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "name" (xs'uniqueName v)
	, maybeToAttr toAttrFrStr "id" (xs'uniqueId v)
	]
instance XmlContent Xs'key where
    fromElem (CElem (Elem "xs:key" as c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (\(c,cc)->
		 (Just (Xs'key (fromAttrs as) a b c), rest))
	      (definite fromElem "(xs:field)+" "xs:key" cb))
	   (definite fromElem "<xs:selector>" "xs:key" ca))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'key as a b c) =
	[CElem (Elem "xs:key" (toAttrs as) (maybe [] toElem a ++ toElem b
					    ++ toElem c))]
instance XmlAttributes Xs'key_Attrs where
    fromAttrs as =
	Xs'key_Attrs
	  { xs'keyName = definiteA fromAttrToStr "xs:key" "name" as
	  , xs'keyId = possibleA fromAttrToStr "id" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "name" (xs'keyName v)
	, maybeToAttr toAttrFrStr "id" (xs'keyId v)
	]
instance XmlContent Xs'keyref where
    fromElem (CElem (Elem "xs:keyref" as c0):rest) =
	(\(a,ca)->
	   (\(b,cb)->
	      (\(c,cc)->
		 (Just (Xs'keyref (fromAttrs as) a b c), rest))
	      (definite fromElem "(xs:field)+" "xs:keyref" cb))
	   (definite fromElem "<xs:selector>" "xs:keyref" ca))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'keyref as a b c) =
	[CElem (Elem "xs:keyref" (toAttrs as) (maybe [] toElem a ++
					       toElem b ++ toElem c))]
instance XmlAttributes Xs'keyref_Attrs where
    fromAttrs as =
	Xs'keyref_Attrs
	  { xs'keyrefName = definiteA fromAttrToStr "xs:keyref" "name" as
	  , xs'keyrefRefer = definiteA fromAttrToStr "xs:keyref" "refer" as
	  , xs'keyrefId = possibleA fromAttrToStr "id" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "name" (xs'keyrefName v)
	, toAttrFrStr "refer" (xs'keyrefRefer v)
	, maybeToAttr toAttrFrStr "id" (xs'keyrefId v)
	]
instance XmlContent Xs'selector where
    fromElem (CElem (Elem "xs:selector" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'selector (fromAttrs as) a), rest))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'selector as a) =
	[CElem (Elem "xs:selector" (toAttrs as) (maybe [] toElem a))]
instance XmlAttributes Xs'selector_Attrs where
    fromAttrs as =
	Xs'selector_Attrs
	  { xs'selectorXpath = definiteA fromAttrToStr "xs:selector" "xpath" as
	  , xs'selectorId = possibleA fromAttrToStr "id" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "xpath" (xs'selectorXpath v)
	, maybeToAttr toAttrFrStr "id" (xs'selectorId v)
	]
instance XmlContent Xs'field where
    fromElem (CElem (Elem "xs:field" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'field (fromAttrs as) a), rest))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'field as a) =
	[CElem (Elem "xs:field" (toAttrs as) (maybe [] toElem a))]
instance XmlAttributes Xs'field_Attrs where
    fromAttrs as =
	Xs'field_Attrs
	  { xs'fieldXpath = definiteA fromAttrToStr "xs:field" "xpath" as
	  , xs'fieldId = possibleA fromAttrToStr "id" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "xpath" (xs'fieldXpath v)
	, maybeToAttr toAttrFrStr "id" (xs'fieldId v)
	]
instance XmlContent Xs'include where
    fromElem (CElem (Elem "xs:include" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'include (fromAttrs as) a), rest))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'include as a) =
	[CElem (Elem "xs:include" (toAttrs as) (maybe [] toElem a))]
instance XmlAttributes Xs'include_Attrs where
    fromAttrs as =
	Xs'include_Attrs
	  { xs'includeSchemaLocation = definiteA fromAttrToStr "xs:include" "schemaLocation" as
	  , xs'includeId = possibleA fromAttrToStr "id" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "schemaLocation" (xs'includeSchemaLocation v)
	, maybeToAttr toAttrFrStr "id" (xs'includeId v)
	]
instance XmlContent Xs'import where
    fromElem (CElem (Elem "xs:import" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'import (fromAttrs as) a), rest))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'import as a) =
	[CElem (Elem "xs:import" (toAttrs as) (maybe [] toElem a))]
instance XmlAttributes Xs'import_Attrs where
    fromAttrs as =
	Xs'import_Attrs
	  { xs'importNamespace = possibleA fromAttrToStr "namespace" as
	  , xs'importSchemaLocation = possibleA fromAttrToStr "schemaLocation" as
	  , xs'importId = possibleA fromAttrToStr "id" as
	  }
    toAttrs v = catMaybes 
	[ maybeToAttr toAttrFrStr "namespace" (xs'importNamespace v)
	, maybeToAttr toAttrFrStr "schemaLocation" (xs'importSchemaLocation v)
	, maybeToAttr toAttrFrStr "id" (xs'importId v)
	]
instance XmlContent Xs'redefine where
    fromElem (CElem (Elem "xs:redefine" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'redefine (fromAttrs as) a), rest))
	(many fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'redefine as a) =
	[CElem (Elem "xs:redefine" (toAttrs as) (concatMap toElem a))]
instance XmlAttributes Xs'redefine_Attrs where
    fromAttrs as =
	Xs'redefine_Attrs
	  { xs'redefineSchemaLocation = definiteA fromAttrToStr "xs:redefine" "schemaLocation" as
	  , xs'redefineId = possibleA fromAttrToStr "id" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "schemaLocation" (xs'redefineSchemaLocation v)
	, maybeToAttr toAttrFrStr "id" (xs'redefineId v)
	]
instance XmlContent Xs'redefine_ where
    fromElem c0 =
	case (fromElem c0) of
	(Just a,rest) -> (Just (Xs'redefine_Xs'annotation a), rest)
	(_,_) ->
		case (fromElem c0) of
		(Just a,rest) -> (Just (Xs'redefine_Xs'simpleType a), rest)
		(_,_) ->
			case (fromElem c0) of
			(Just a,rest) -> (Just (Xs'redefine_Xs'complexType a), rest)
			(_,_) ->
				case (fromElem c0) of
				(Just a,rest) -> (Just (Xs'redefine_Xs'attributeGroup a), rest)
				(_,_) ->
					case (fromElem c0) of
					(Just a,rest) -> (Just (Xs'redefine_Xs'group a), rest)
					(_,_) ->
					    (Nothing, c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'redefine_Xs'annotation a) = toElem a
    toElem (Xs'redefine_Xs'simpleType a) = toElem a
    toElem (Xs'redefine_Xs'complexType a) = toElem a
    toElem (Xs'redefine_Xs'attributeGroup a) = toElem a
    toElem (Xs'redefine_Xs'group a) = toElem a
instance XmlContent Xs'notation where
    fromElem (CElem (Elem "xs:notation" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'notation (fromAttrs as) a), rest))
	(fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'notation as a) =
	[CElem (Elem "xs:notation" (toAttrs as) (maybe [] toElem a))]
instance XmlAttributes Xs'notation_Attrs where
    fromAttrs as =
	Xs'notation_Attrs
	  { xs'notationName = definiteA fromAttrToStr "xs:notation" "name" as
	  , xs'notationId = possibleA fromAttrToStr "id" as
	  , xs'notationPublic = definiteA fromAttrToStr "xs:notation" "public" as
	  , xs'notationSystem = possibleA fromAttrToStr "system" as
	  }
    toAttrs v = catMaybes 
	[ toAttrFrStr "name" (xs'notationName v)
	, maybeToAttr toAttrFrStr "id" (xs'notationId v)
	, toAttrFrStr "public" (xs'notationPublic v)
	, maybeToAttr toAttrFrStr "system" (xs'notationSystem v)
	]
instance XmlContent Xs'annotation where
    fromElem (CElem (Elem "xs:annotation" [] c0):rest) =
	(\(a,ca)->
	   (Just (Xs'annotation a), rest))
	(many fromElem c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'annotation a) =
	[CElem (Elem "xs:annotation" [] (concatMap toElem a))]
instance XmlContent Xs'annotation_ where
    fromElem c0 =
	case (fromElem c0) of
	(Just a,rest) -> (Just (Xs'annotation_Xs'appinfo a), rest)
	(_,_) ->
		case (fromElem c0) of
		(Just a,rest) -> (Just (Xs'annotation_Xs'documentation a), rest)
		(_,_) ->
		    (Nothing, c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'annotation_Xs'appinfo a) = toElem a
    toElem (Xs'annotation_Xs'documentation a) = toElem a
instance XmlContent Xs'appinfo where
    fromElem (CElem (Elem "xs:appinfo" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'appinfo (fromAttrs as) a), rest))
	(definite fromElem "ANY" "xs:appinfo" c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'appinfo as a) =
	[CElem (Elem "xs:appinfo" (toAttrs as) (toElem a))]
instance XmlAttributes Xs'appinfo_Attrs where
    fromAttrs as =
	Xs'appinfo_Attrs
	  { xs'appinfoSource = possibleA fromAttrToStr "source" as
	  , xs'appinfoId = possibleA fromAttrToStr "id" as
	  }
    toAttrs v = catMaybes 
	[ maybeToAttr toAttrFrStr "source" (xs'appinfoSource v)
	, maybeToAttr toAttrFrStr "id" (xs'appinfoId v)
	]
instance XmlContent Xs'documentation where
    fromElem (CElem (Elem "xs:documentation" as c0):rest) =
	(\(a,ca)->
	   (Just (Xs'documentation (fromAttrs as) a), rest))
	(definite fromElem "ANY" "xs:documentation" c0)
    fromElem (CMisc _:rest) = fromElem rest
    fromElem rest = (Nothing, rest)
    toElem (Xs'documentation as a) =
	[CElem (Elem "xs:documentation" (toAttrs as) (toElem a))]
instance XmlAttributes Xs'documentation_Attrs where
    fromAttrs as =
	Xs'documentation_Attrs
	  { xs'documentationSource = possibleA fromAttrToStr "source" as
	  , xs'documentationId = possibleA fromAttrToStr "id" as
	  , xs'documentationXml'lang = possibleA fromAttrToStr "xml:lang" as
	  }
    toAttrs v = catMaybes 
	[ maybeToAttr toAttrFrStr "source" (xs'documentationSource v)
	, maybeToAttr toAttrFrStr "id" (xs'documentationId v)
	, maybeToAttr toAttrFrStr "xml:lang" (xs'documentationXml'lang v)
	]


{-Done-}
